package com.cn;

import com.sun.org.apache.xpath.internal.SourceTree;

/**
 * Created by ZYM on 2017/9/28.
 * 实例工厂
 */
public class PeopleFactory {

    public static People getPeople(String type)  {
        try{
            if(type.equalsIgnoreCase("People1")) {
                return People1.class.newInstance();

            } else if(type.equalsIgnoreCase("People2")) {
                return People2.class.newInstance();
            } else {
                System.out.println("找不到相应的实例化类");
                return null;
            }



//        // type是类的全路径
//        Class people = Class.forName(type);
//        return (People) people.newInstance();
    }catch (Exception e) {
        System.out.println(e);
        return null;
    }



//        Class people = Class.forName(type);
//        return (People)people.newInstance();
    }

}
